package com.example.demo.controller;

import com.example.demo.entity.TbOrder;
import com.example.demo.service.UserService;
import com.example.demo.util.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController //Controller+ResponseBody
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;

    @GetMapping("/show")
    public ResultMsg show(){
        ResultMsg resultMsg = userService.show();
        return resultMsg;
    }
    //@GetMapping("/modify")
    @PostMapping("/modify")
    public ResultMsg modify(@RequestBody TbOrder tbOrder){
        return userService.modify(tbOrder);
    }

    @GetMapping("/selectlike")
    public ResultMsg selectlike(@RequestParam(defaultValue = "") String key){
        return userService.show(key);
    }

    @GetMapping("/selectpage")
    public ResultMsg selectpage(@RequestParam(defaultValue = "1") int current,@RequestParam(defaultValue = "2") int size){
        return userService.show(current,size);
    }

    @GetMapping("/delete/{id}")
    public ResultMsg delete(@PathVariable("id")String id){
        return userService.deleteById(id);
    }

}
